<template>
	<!--学生课堂活动列表 -->
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center flex_0_ibhf" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
			    <view class='flex flex-wrap align-center justify-between flex-sub fd0_0_ibhf'>
			        <view class='flex flex-wrap align-center fd0_0_c0_ibhf' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
			            <text class='fu-iconfont2  fd0_0_c0_c0_ibhf'>&#xE794;</text>
			        </view>
			        <view class='flex flex-wrap align-stretch justify-center'>
			            <text class='fd0_0_c1_c0_ibhf'>课堂活动</text>
			        </view>
			        <view class='flex flex-wrap align-center justify-end fd0_0_c0_ibhf'>
			        </view>
			    </view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始--> 
			<view class="flex flex-direction align-stretch benben-flex-layout">
				<view>
					<benben-flex-tabs class-name='benbenTabsfd1_0_ibhf' v-model="tab" ref="benben_tabsfd1_0"
						select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false'
						:open-sticky='true' :top='88' :is-show-content='false' :scrollspy='false'
						:tabs-info.sync="tabsInfofd1_0">

						<scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
							class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left="tabsInfofd1_0.moveX"
							scroll-with-animation="all .3s ease" :show-scrollbar='false' :enhanced="true">
							<view class="benben-tabs-content" id="benben_tabsfd1_0-content">
								<view id="benben_tabsfd1_0-title"
									class="benben-tabs-title flex flex align-center justify-around">
									
									<view
										:class="{ 'checkTitlefd1_0_ibhf': tab == '2', 'flex flex-wrap align-center': true }"
										@tap="getlist(2)" :id="`benben_tabsfd1_0-title-item-${'2'}`">

										<text>未参与</text>

									</view>
									<view
										:class="{ 'checkTitlefd1_0_ibhf': tab == '1', 'flex flex-wrap align-center': true }"
										@tap="getlist(1)" :id="`benben_tabsfd1_0-title-item-${'1'}`">
									
										<text>已参与</text>
									
									</view>
								</view>
								<view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
									id="benben_tabsfd1_0-line"
									class="benben-tabs-line flex benben-flex-tabs-line linefd1_0_ibhf"
									:class="{'benben-tabs-line-active':tabsInfofd1_0.isInit}"></view>
							</view>
						</scroll-view>

					</benben-flex-tabs>

				</view>
				<view class='flex flex-direction align-stretch fd1_1_ibhf'>
				
					<!-- activity_status ns  未开始 ing 进行中  end已结束-->
					<template v-for='(item,key0) in list' v-if="list.length>0 && isup">
						<view class='flex flex-wrap align-center justify-between fd1_1_c0_ibhf' :key='key0'
							@tap.stop="jump(item,key0)">
							<view class='flex flex-direction flex-wrap align-stretch justify-between flex-sub'>
								<view class="fd1_1_c0_c0_c0_ibhf flex">
									<view class=''>{{item.name}}</view>
									
								</view>
									<text class='fd1_1_c0_c0_c1_ibhf' v-if="item.activity_status=='ing'">发布时间:{{item.start_time}}</text>
									<text class='fd1_1_c0_c0_c1_ibhf' v-if="item.activity_status=='end'">结束时间:{{item.end_time}}</text>
									<text class='fd1_1_c0_c0_c1_ibhf' v-if=" item.activity_status=='ing' && item.end_time">截止时间:{{item.end_time}}</text>
							</view>
							<view class='flex flex-wrap align-center'>
								<view class="zt"  v-if=" item.activity_status=='ns'">未开始</view>
								<view class="zt"  v-if=" item.activity_status=='ing'">进行中</view>
								<view class="zt js"  v-if=" item.activity_status=='end'">已结束</view>
								<text class='fu-iconfont2'>&#xe7f2;</text>
							</view>
						</view>
					</template>
					<view v-if="list.length==0 && isup">
						<slot>
							<view class="public-page-empty">
								<image src='/static/global/order.png'></image>
								<view class="txt">暂无数据</view>
							</view>
						</slot>
					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</page-body>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				id:'',
				isup: false,
				"tabsInfofd1_0": {
					lineleft: '',
					lineWidth: '',
					moveX: 0,
					scrollX: 0,
					PageScrollX: 0,
					isInit: false
				},
				"tab": "1",
				teaching_id:'',//授课id
				"list": [],
					
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) { 
			this.id=options.course
			this.teaching_id=options.teaching_id
			if (global.appTabBarType) this.toHomeDiy()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
				this.getlist(2)
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			jump(item, index) {
					// 未参与的
				if(this.tab==2){
					if(item.activity_status=='ns'){
						this.$message.info('活动未开始')
						return
					}else if(item.activity_status=='end'){
						this.$message.info('活动已结束')
						return
					}
				}
				console.log('status:'+item.activity_status)
				// this.tab==1 已参与 2未参与  status 0 已结束 1未结束
				// 3 抢答 7讨论 4 投票 5随堂测 6数字人选人
				item.notice_type=item.uuid=='quick'?3:item.uuid=='vote'?4:item.uuid=='classroom_test'?5:item.uuid=='call'?6:item.uuid=='topic'?7:''
				if (item.notice_type == 3) {
					// 抢答
					if(this.tab==1){
						let end_time=item.end_time?item.end_time:''
						uni.navigateTo({
							url: "/pages/suitc/qdjg/qdjg?type=1&aid="+item.aid+'&id='+item.quick_id+'&time='+item.start_time+'&time1='+end_time
						})
					}else{
						if(item.status==0){
							let end_time=item.end_time?item.end_time:''
							//已结束
							uni.navigateTo({
								url: "/pages/suitc/qdjg/qdjg?type=2&status=2&aid="+item.aid+'&time='+item.start_time+'&time1='+end_time
							})
						}else{
							// 去抢答
							let end_time=item.end_time?item.end_time:''
							uni.navigateTo({
								url: "/pages/suitc/qd/qd?aid="+item.aid+'&msgid='+item.aid+'&time='+item.start_time+'&time1='+end_time
							})
						}
					}
					
					let type=item.status==0?1:2
					
				} else if (item.notice_type == 7) {
					// 讨论
					let end_time=item.end_time?item.end_time:''
					let status=item.activity_status=='ing'?1:0
					if(this.tab==1){
						// 讨论
						// `/pages/course/subTalk/subTalk?aid=${aid}&name=${subject}&teachin=${this.teachin}
						uni.navigateTo({
							url: "/pages/activity/talk/talk?teachin="+item.teaching_id+'&activity_id='+item.activity_id+'&type='+this.tab+'&status='+status+'&aid='+item.aid+'&time='+item.start_time+'&time1='+end_time+'&course='+this.id+'&topicdiscussion_id='+item.topicdiscussion_id
						})
					}else{
						uni.navigateTo({
							url: "/pages/activity/talk/talk?teachin="+item.teaching_id+'&activity_id='+item.activity_id+'&type='+this.tab+'&status='+status+'&aid='+item.aid+'&time='+item.start_time+'&time1='+end_time+'&course='+this.id+'&topicdiscussion_id='+item.topicdiscussion_id
						})
					}
					
				} else if (item.notice_type == 6) {
					//数字人选人
					let end_time=item.end_time?item.end_time:''
					if(this.tab==1){
						uni.navigateTo({
							url: "/pages/activity/xuanrenjg/xuanrenjg?aid="+item.aid+'&type=1&messid='+item.aid+'&time='+item.start_time+'&time1='+end_time+'&status='+item.status+'&teaching_id='+item.teaching_id
						})
					}else{
						if(item.status==0){
							uni.navigateTo({
								url: "/pages/activity/xuanrenjg/xuanrenjg?aid="+item.aid+'6&type=2&messid='+item.aid+'&time='+item.start_time+'&time1='+end_time+'&status='+item.status+'&teaching_id='+item.teaching_id
							})
						}
						
						
					}
					
				} else if (item.notice_type == 4) {
					// 投票
					// 已参与
					let status=item.activity_status=='ing'?1:0
					if(this.tab==1){
						uni.navigateTo({
							url: "/pages/activity/tpjg/tpjg?aid="+item.aid+'&type=1'+'&time='+item.start_time+'&time1='+item.end_time
						})
					}else{
						// 未参与 
						if(status==0){
							// 已结束
							uni.navigateTo({
								url: "/pages/activity/tpjg/tpjg?type=2&time="+item.start_time+'&time1='+item.end_time
							})
						}else{
							// 未结束
							uni.navigateTo({
								url: "/pages/activity/tp/tp?votequestion_id="+item.activity_id+'&aid='+item.aid
							})
						}
					}
				
					
				} else if (item.notice_type == 5) {
					//随堂测试
					let end_time=item.end_time?item.end_time:''
					if(this.tab==1){
						uni.navigateTo({
							url: "/pages/suitc/csjg/csjg?type=1&id="+item.activity_id+'&time='+item.start_time+'&time1='+end_time
						})
					}else{
						// 未参与
						if(item.status==0){
							// 已结束
							uni.navigateTo({
								url: "/pages/suitc/csjg/csjg?type=2&id="+item.exampaper_id+"&time="+item.start_time+'&time1='+end_time
							})
						}else{
							uni.navigateTo({
								url:'/pages/kc/answer/answer?type=4&homeid='+item.activity_id+'&aid='+item.aid+'&messid='+item.aid+'&time='+item.start_time+'&time1='+end_time
							})
							// 未结束
							// uni.navigateTo({
							// 	url: "/pages/suitc/ceshi/ceshi?id="+item.exampaper_id+'&time='+item.start_time+'&time1='+end_time+'&messid='+item.aid
							// })
						}
					}
				} 

			},
			async getlist(type){
				this.tab=type
				console.log(type)
				let res = await this.$api.post(global.apiUrls.post691d85801e89f, {
						course_id:this.id,
						// teaching_id:this.teaching_id,
						is_take:this.tab==2?'0':'1',//参与1，未参与：0
				});
				this.isup = true
				if (res.data.code != 1) {
					this.$message.info(res.data.msg);
					return
				}
				this.list=res.data.data
				console.log(res.data.data)
				// this.iseditopen=false
				// this.getlist()
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(255, 255, 255, 1);
		background-size: 100% auto;

		.checkTitlefd1_0_ibhf {
			font-weight: 700 !important;
			font-size: 28rpx !important;
			color: #333 !important;
			background-color: rgba(255, 255, 255, 1) !important;
		}

		.linefd1_0_ibhf {
			width: 40rpx;
			height: 8rpx;
			top: 80rpx;
			background: #145efd;
			background-size: 100% auto !important;
			border-radius: 4rpx;
		}

		.fd1_1_ibhf {
			padding: 0rpx 24rpx 0rpx 24rpx;
		}

		.fd1_1_c0_ibhf {
			border-bottom: 1px solid #eee;
			padding: 24rpx 0rpx 24rpx 0rpx;
		}

		.fd1_1_c0_c0_c0_ibhf {
			font-size: 32rpx;
			color: #333333;
			margin: 0rpx 0rpx 24rpx 0rpx;
		}
		.zt {
			margin-left: 32rpx;
                width: 92rpx;
                height: 40rpx;
                line-height: 40rpx;
                text-align: center;
                background:#F4F8FD;
                background-size: 100% auto;
                border-radius: 12rpx;
				font-size: 24rpx;
                color: #1C5EFC;
				padding: 0 10rpx;
				
			
            }
			.js{
				 background:#F5F5F5;
				  color: #999999;
			}
		.fd1_1_c0_c0_c1_ibhf {
			font-size: 24rpx;
			color: #999999;
		}

		.flex_0_ibhf {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			top: 0rpx;
			background: #fff;
			background-size: 100% auto !important;

			.fd0_0_ibhf {
				padding: 0rpx 32rpx 0rpx 32rpx;

				.fd0_0_c1_c0_ibhf {
					font-size: 36rpx;
					font-weight: 700;
					color: #333333;
					line-height: 50rpx;
				}
			}
		}

		.fd0_0_c0_ibhf {
			width: 120rpx;

			.fd0_0_c0_c0_ibhf {
				font-size: 36rpx;
				color: #333;
			}
		}
	}

	::v-deep .benbenTabsfd1_0_ibhf {
		width: 750rpx;
		height: 90rpx;
		white-space: nowrap;
		background: #fff;
		text-align: center;
	}
	.public-page-empty {
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			padding: 120upx 0 0 0;
		
			image {
				width: 300rpx;
				height: 300rpx;
			}
		
			.txt {
				font-size: 28upx;
				color: $uni-text-color;
				text-align: center;
				line-height: 100upx;
				color: var(--benben-loading-color, #999999);
			}
		
			.loadTips {
				line-height: 30upx;
			}
		
			.btn {
				width: 260upx;
				height: 78upx;
				line-height: 78upx;
				background: linear-gradient(309deg, rgba(254, 49, 0, 1) 0%, rgba(255, 90, 16, 1) 100%);
				opacity: 1;
				border-radius: 44upx;
				font-size: 28upx;
				color: #fff;
				text-align: center;
				margin-top: 100upx;
			}
		}
	
	
</style>
